/*    */ package tools;
/*    */ 
/*    */ import java.net.InetAddress;
/*    */ import java.net.NetworkInterface;
/*    */ import java.net.SocketException;
/*    */ import java.util.Enumeration;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class MacAddressTool
/*    */ {
/*    */   public static String getMacAddress(boolean ipAddress) {
/* 22 */     String macs = null;
/* 23 */     String localip = null;
/*    */     try {
/* 25 */       Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
/*    */       
/* 27 */       boolean finded = false;
/* 28 */       while (netInterfaces.hasMoreElements() && !finded) {
/* 29 */         NetworkInterface ni = netInterfaces.nextElement();
/* 30 */         Enumeration<InetAddress> address = ni.getInetAddresses();
/* 31 */         while (address.hasMoreElements()) {
/* 32 */           InetAddress inetAddress = address.nextElement();
/* 33 */           String ip = inetAddress.getHostAddress();
/* 34 */           if (ip.contains(":") || ip.startsWith("221.231.") || ip.equalsIgnoreCase("127.0.0.1") || ip.equalsIgnoreCase("59.56.111.127")) {
/*    */             continue;
/*    */           }
/*    */           
/* 38 */           if (!inetAddress.isSiteLocalAddress() && !inetAddress.isLoopbackAddress()) {
/* 39 */             localip = inetAddress.getHostAddress();
/* 40 */             byte[] mac = ni.getHardwareAddress();
/* 41 */             if (mac == null) {
/*    */               continue;
/*    */             }
/* 44 */             StringBuilder sb = new StringBuilder();
/* 45 */             for (int i = 0; i < mac.length; i++) {
/* 46 */               if (i != 0) {
/* 47 */                 sb.append("-");
/*    */               }
/* 49 */               String str = Integer.toHexString(mac[i] & 0xFF);
/* 50 */               sb.append((str.length() == 1) ? (Character.MIN_VALUE + str) : str);
/*    */             } 
/* 52 */             macs = sb.toString().toUpperCase();
/*    */ 
/*    */             
/* 55 */             finded = true; break;
/*    */           } 
/* 57 */           if (inetAddress.isSiteLocalAddress() && !inetAddress.isLoopbackAddress()) {
/* 58 */             localip = inetAddress.getHostAddress();
/* 59 */             byte[] mac = ni.getHardwareAddress();
/* 60 */             StringBuilder sb = new StringBuilder();
/* 61 */             for (int i = 0; i < mac.length; i++) {
/* 62 */               if (i != 0) {
/* 63 */                 sb.append("-");
/*    */               }
/* 65 */               String str = Integer.toHexString(mac[i] & 0xFF);
/* 66 */               sb.append((str.length() == 1) ? (Character.MIN_VALUE + str) : str);
/*    */             } 
/* 68 */             macs = sb.toString().toUpperCase();
/*    */ 
/*    */             
/* 71 */             finded = true;
/*    */           }
/*    */         
/*    */         } 
/*    */       } 
/* 76 */     } catch (SocketException e) {
/* 77 */       e.printStackTrace();
/*    */     } 
/* 79 */     return ipAddress ? localip : macs;
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\tools\MacAddressTool.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */